package com.example.shushiyunsst.fragment.main.home.recycler.provider;

import android.content.Context;
import android.view.View;

import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.example.library_common.adapter.multi.JssMultiItemViewHolder;
import com.example.library_common.adapter.multi.JssNewMultipleAdapter;
import com.example.library_common.album.view.grid_view.XGridLayout;
import com.example.library_common.album.view.grid_view.adapter.CommAdapter;
import com.example.library_common.album.view.grid_view.adapter.XQuickViewHolder;
import com.example.shushiyunsst.R;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.MinerEntity;
import com.example.shushiyunsst.fragment.main.home.recycler.bean.MinerEntityWrapper;
import com.senon.modularapp.util.JssSpannableString;

import java.util.List;

public class MinerProvider extends JssMultiItemViewHolder<MinerEntityWrapper> {


    private CommAdapter<MinerEntity> mAdapter;

    public MinerProvider(View view) {
        super(view);
    }

    @Override
    public int getItemLayout() {
        return R.layout.miner_provider_layout;
    }

    @Override
    public void convert(Context context, MinerEntityWrapper minerEntity) {
        super.convert(context, minerEntity);

        XGridLayout mLineLayout = findView(R.id.mLineLayout);

        if (mAdapter == null) {
            mAdapter = new CommAdapter<MinerEntity>(
                    context,
//                    minerEntity.getList(),
                    R.layout.miner_provider_item_layout
            ) {
                @Override
                public void convert(XQuickViewHolder holder, MinerEntity item, int position) {
                    String createTime = item.getCreateTime();

                    String content = item.getContent();

                    holder.setText(R.id.titleTemplate, content)
                            .setText(R.id.timeTv, createTime);

                }
            };
        }
        if (mLineLayout != null) {
            if (adapter instanceof JssNewMultipleAdapter) {
                mLineLayout.setAdapter(mAdapter, ((JssNewMultipleAdapter) adapter).getLifecycle());
            }

        }
        List<MinerEntity> list = minerEntity.getList();

        mAdapter.clear();
        mAdapter.addAll(list);

        setVisible(R.id.sysMsg,list.size()>0)
                .setViewVisible(R.id.mEmptyTv,list.size()<=0);

//        setText(R.id.minerStolen,minerEntity.getMine_be_stolen_time()+"小时")
//                .setText(R.id.minerTake,minerEntity.getMine_be_to_take_time()+"小时");
    }
}
